#include <bits/stdc++.h>

using namespace std;

const int N = 205;
int m,n;
int b[N];
bool stu[N], a[N][N];
bool find(int x) {
	for (int i = 1; i <= n; i++) {
		if(a[x][i] && !stu[i]) {
			stu[i] = true;
			if(!b[i] || find(b[i])){
				b[i] = x;
				return true;
			}
		}
	}
	return false;
}
int main(){
	while(cin >> m >> n) {	
	memset(b, 0, sizeof b);
	memset(a, 0, sizeof a);
	for(int j = 1; j <= m; j++) {
		int c;
		cin >> c;
		for (int i = 1; i <= c; i++) {
			int f;
			cin >> f;
			a[j][f] = true;
		}
	}
	int ans = 0;
    for (int i = 1; i <= m; i++) {
		memset(stu, 0, sizeof stu);
		if(find(i)) ans++;
	}
	cout << m - ans << endl;
	}
	return 0;
}
